import config from '@/config';
import RequestBase from '@/utils/request.js';

const baseRequest = new RequestBase(config.baseUrl);
const safetyRequest = new RequestBase(config.safetyUrl);
const equipmentRequest = new RequestBase(config.equipment);
const specialWorkRequest = new RequestBase(config.specialWorkUrl);
const doubleDefenseRequest = new RequestBase(config.doubleDefenseUrl);
const basicInfoRequest = new RequestBase(config.basicInfoUrl);

//查询分厂
export function getLevelTwoArea() {
  return basicInfoRequest.get('/info/web/factory-area/getLevelTwoArea');
}

//查询工段/区域
export function getSonArea(areaId) {
  return safetyRequest.get(`/bsci/factory-area/getSonArea`, { id: areaId });
}

// 获取设备台账
export function queryDeviceStandingBook(data) {
  return equipmentRequest.get('/dfm/deviceLedger/v2/list', data);
}

/**
 * 新增停送电作业票
 */
export function createElectricProject(data) {
  return specialWorkRequest.put('/electric/create', data);
}

/**
 * 查询详情
 */
export function getElectricDetail(id) {
  return specialWorkRequest.get(`/electric/detail/${id}`);
}

/**
 * /special-work/electric/history/{id} 签批记录
 */
export function getElectricHistory(id) {
  return specialWorkRequest.get(`/electric/history/${id}`);
}

/**
 * /special-work/electric/page 分页查询
 */
export function getElectricList(data) {
  return specialWorkRequest.get(`/electric/page`, data);
}

/**
 * /special-work/electric/todo/count  待办数量
 */
export function getElectricTodoCount() {
  return specialWorkRequest.get(`/electric/todo/count`);
}

/**
 * /special-work/electric/todo/page  待办分页查询
 */
export function getElectricTodoList(data) {
  return specialWorkRequest.get(`/electric/todo/page`, data);
}

/**
 * 停电审核
 */
export function stopCheck(data) {
  return specialWorkRequest.put('/electric/stop/check', data);
}

/**
 * 送电审核
 */
export function startCheck(data) {
  return specialWorkRequest.put('/electric/start/check', data);
}

/**
 * 停电审批
 */
export function stopApprove(data) {
  return specialWorkRequest.put('/electric/stop/approve', data);
}

/**
 * 送电审批
 */
export function startApprove(data) {
  return specialWorkRequest.put('/electric/start/approve', data);
}

/**
 * 送电申请
 */
export function startElectric(data) {
  return specialWorkRequest.put('/electric/start', data);
}

/**
 * 停电确认
 */
export function stopConfirm(data) {
  return specialWorkRequest.put('/electric/stop/confirm', data);
}

/**
 * 送电确认
 */
export function startConfirm(data) {
  return specialWorkRequest.put('/electric/start/confirm', data);
}

/**
 * 获取 审核代办人
 */
export function checkUserTransfer(data) {
  // return baseRequest.get('/system/user/electric/checkUser');
  return safetyRequest.get('/bsci/staff/electric/checkUser', data);
}

/**
 * 获取审批代办人
 */
export function approveUserTransfer(data) {
  // return baseRequest.get('/system/user/electric/approveUser');
  return safetyRequest.get('/bsci/staff/electric/approveUser', data);
}

/**
 * 转发
 */
export function transmit(data) {
  return specialWorkRequest.put('/electric/transmit', data);
}

/**
 * 修改提交停电作业票
 */
export function stopUpdate(data) {
  return specialWorkRequest.post('/electric/stop/update', data);
}

/**
 * 修改提交送电作业票
 */
export function startUpdate(data) {
  return specialWorkRequest.post('/electric/start/update', data);
}
